import java.util.Scanner;
import java.util.TreeSet;

/**
 * 整形数组合并
 */
public class ArrayMerge {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            TreeSet<Integer> set = new TreeSet<>();
            int num1 = scanner.nextInt();
            for (int i=0; i<num1; i++) {
                set.add(scanner.nextInt());
            }
            int num2 = scanner.nextInt();
            for (int i=0; i<num2; i++) {
                set.add(scanner.nextInt());
            }
            set.forEach(System.out::print);
            System.out.println();
        }
    }
}
